import { createStore } from "vuex";
let audioObj=new Audio()
audioObj.src="0"
let songDatas=[]
export default createStore({
    state: {
        songCover:'',
        audioObj:audioObj,
        songDatas:songDatas,
        once:true
       
    },
    mutations: {
        CHOOSE(state,value)
        {
            state.songCover=value
            console.log(state.songCover);
            
        },
        PLAY(state,value){
            console.log(state.audioObj);
            state.audioObj.src=value
            console.log(state.audioObj.src);
            state.audioObj.play();
        },

        ADD_SONG_DATA(state, songData) {
           
                state.songDatas.push(songData);
            
        }
       
        
    },
    actions: {
        choose:function(context,value){
            console.log('choose被调用了',value);
            context.commit('CHOOSE',value)
        },
        play(context,value){
            console.log('play被调用',value);
            context.commit('PLAY',value)

        }
    },
    modules: {
    }
})